﻿Public Class frm_speedreport

    Dim _settings As New Settings

    Private Sub cmd_OK_Click(sender As Object, e As EventArgs) Handles cmd_OK.Click
        Me.Close()
    End Sub

    Private Sub frm_speedreport_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim _tools As New Tools

        _settings = frm_main.GetSettings

        rtb_speedreport.Text = _settings.GetSetSpeedreportTemplate

        'Variablen ersetzten
        rtb_speedreport.Text = rtb_speedreport.Text.Replace("%%USER%%", _settings.GetSetSpeedreportUsername)
        rtb_speedreport.Text = rtb_speedreport.Text.Replace("%%CONNECTION%%", _settings.GetSetSpeedreportConnection)
        rtb_speedreport.Text = rtb_speedreport.Text.Replace("%%COMMENT%%", _settings.GetSetSpeedreportComment)
        rtb_speedreport.Text = rtb_speedreport.Text.Replace("%%SPEED%%", frm_main.GetSetMaxDownloadSpeedAchieved.ToString & " KB/s")
        rtb_speedreport.Text = rtb_speedreport.Text.Replace("%%SFDL_DESC%%", frm_main.GetSetCurrentSFDLFile.GetSetDescription)
        rtb_speedreport.Text = rtb_speedreport.Text.Replace("%%SFDL_UPPER%%", frm_main.GetSetCurrentSFDLFile.GetsetUploader)
        rtb_speedreport.Text = rtb_speedreport.Text.Replace("%%TIME%%", _tools.mSecToHMS(frm_main.GetSetElapsedDownloadTime))




    End Sub

    Private Sub LinkExplorer_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkExplorer.LinkClicked

        Dim _tools As New Tools
        Dim _download_dir As String

        Try

            If _settings.GetSetCreateDownloadDir Then

                If _settings.GetSetCreateDownloadDirUseDescription = True And String.IsNullOrEmpty(frm_main.GetSetCurrentSFDLFile.GetSetDescription) = False Then
                    _download_dir = IO.Path.Combine(_settings.GetSetDownloadDirectory, frm_main.GetSetCurrentSFDLFile.GetSetDescription)
                Else
                    _download_dir = IO.Path.Combine(_settings.GetSetDownloadDirectory, IO.Path.GetFileNameWithoutExtension(frm_main.GetSetCurrentSFDLFilePath))
                End If

            Else
                _download_dir = _settings.GetSetDownloadDirectory
            End If

            _tools.OpenExplorer(_download_dir & "\")

        Catch ex As Exception
            MessageBox.Show("Verzeichniss konnte nicht geöffnet werden!", "Sorry...", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub
End Class